package com.cn.plugin.controller;

import com.cn.plugin.entity.Order;
import com.cn.plugin.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : Hydra
 * @date: 2021/3/10 9:29
 * @version: 1.0
 */
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/query/{orderId}")
    public Order query(@PathVariable Long orderId){
        return orderService.getOrder(orderId);
    }

    @GetMapping("/query/all")
    public String queryAll(){
        return orderService.getAllOrder().toString();
    }

    @GetMapping("/query2/{orderId}/{status}")
    public String query2(@PathVariable Long orderId,@PathVariable Integer status){
        return orderService.getOrder(orderId,status).toString();
    }

    @GetMapping("/update/{orderId}")
    public int update(@PathVariable Long orderId){
        return orderService.updateById(orderId);
    }

}
